package java03.bll;

import java03.bll.standard.Shape;

// 正方形Square继承了图形Shape
// 正方形Square称为子类型，Shape称为父类型
// 继承表示子类型Square与父类型签订了一份协议
// 子类型Square必须遵从父类型Shape规定的契约
public class Square extends Shape {
    private double width;

    public Square(double width) {
        this.width = width;
    }

    @Override
    public double getArea() {
        return width * width + this.getOffset();
    }

    @Override
    public double getPerimeter() {
        return width * 4 + getOffset();
    }
}
